Skip to main content

Working with Images

What is an Image?

In the context of digital technology and computing, images are represented as a grid of pixels, with each pixel containing information about color and intensity.

Types of images supported by ImagesJS

  • Currently ImageJS supports images with these characteristics:
TIFFJPEGPNG
Bits per channel8 or 16 bits8 bits8 or 16 bits
Bits per Alpha8 or 16 bitsN/A8 or 16 bits
Compressionyes/no(may be destructive)no(may be destructive)yes
Color ModelRGB and grayscaleRGB and grayscaleRGB and grayscale
Can be loaded in this format
Can be saved in this format

Image coordinates

The origin point has coordinates (0,0) and is located in the top-left corner of an image.

Image coordinates

So, if we want to get a certain pixel on the image we will be counting the distance from image's top-left corner.

//We will receive 20th row and 10th column
//from the top-left corner.
const pixel = image.getPixel(10, 20);

Properties

In ImageJS main properties of an image are:

  • width

  • height

  • data: typed array with information about image's pixels.

  • Color model: the abstract model of how pixel colors are formed.

  • Bit depth: number of bits allocated to each channel.

  • Number of channels/components: number of color channels that each pixel has. Grey image has one, RGB-type of image has three.

  • Metadata: data about data.

The latter ones matter most in features that involve two images, like hypotenuse method or subtraction method. It simply will not work if images are not compatible by bit depth, color model or size.

Features

Currently, there are several ways of processing an image:

  • Filtering: filters usually apply some sort of kernel to change an image.

  • Comparison: these features compare two images for further feature matching between the two.

  • Geometry: this part of ImageJS allows rotating and resizing an image.

  • Morphology: enables shape analysis and shape identification.

placeholderplaceholder
Ran in 0.00μs (Infinity ops/s)